package thread;

public class ThreadDemo3 {
    public static void main(String[] args) {
        //第一种创建方式: 继承Thread类重写run方法
        Thread t = new Thread(){
            public void run(){
                for(int i=0; i<1000;i++){
                    System.out.println("123321");
                }
            }
        };
        Thread t1 = new Thread(t);
        t1.start();

        //第二种创建方式: 实现Runnable接口并重写run方法
        Runnable r = new Runnable(){
            public void run(){
                for(int i = 0; i<1000; i++){
                    System.out.println("888888");
                }
            }
        };
        Thread t2 = new Thread(r);
        t2.start();


        //第三种创建方式: 使用lambda表达式
        Thread t3 = new Thread(()-> {
            for (int i = 0; i < 1000; i++) {
                System.out.println("999999");
            }
        });
        t3.start();
    }
}
